<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            position: absolute;
            left: 0px;
            top: 0px;
        }
        .menu{
            width: 100px;
            height: 200px;
            background: lightpink;
            position: absolute;
            display: none;

        }

    </style>
</head>
<body>
    <div class="box"></div>
    <div class="menu"></div>
</body>
</html>
<script>
    var boxEle = document.querySelector(".box");
    document.onmousemove = function(e){
        var x = e.clientX;
        var y = e.clientY;
        console.log(x,y);
        boxEle.style.left = x + "px";
        boxEle.style.top = y + "px";
        boxEle.innerHTML = `x:${x}px;y:${y}px`;
    }
    var menuEle = document.querySelector(".menu");
    document.oncontextmenu = function(e){
        var x = e.clientX;
        var y = e.clientY;
        menuEle.style.display = "block";
        menuEle.style.left = x + "px";
        menuEle.style.top = y + "px";
        e.preventDefault();
    }
    document.onclick = function(){
        menuEle.style.display = "none";
    }
</script>